class Solution:
    def dayOfYear(self, date: str) -> int:
        days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
        year = int(date[:4])
        month = int(date[5:7])
        is_run = False
        if not year % 400:
            is_run = True
        elif year % 100 and not year % 4:
            is_run = True
        return int(date[8:]) + sum(days_of_month[:month-1]) + (1 if is_run and month > 2 else 0)
